Skip to content

feat: add admin /logs command to view bot log lines#39

Merged
BigMichi1 merged 1 commit into
mainfrom
feat/admin-logs-command
May 24, 2026
Merged

feat: add admin /logs command to view bot log lines#39
BigMichi1 merged 1 commit into
mainfrom
feat/admin-logs-command

Conversation

@BigMichi1
Copy link
Copy Markdown
Owner

Summary

Adds a new admin-only /logs slash command that displays the last N lines of the bot's combined.log file directly in Discord.

Changes

  • src/bot/commands/logs.ts — New /logs command
    • Admin-only (ManageMessages permission, same gate as /backfill)
    • Optional lines integer parameter (1–100, defaults to 20)
    • Reads the tail of logs/combined.log and returns it in a code-block embed (ephemeral)
    • Gracefully truncates content that would exceed Discord's 4096-char embed limit
  • src/bot/bot.ts — Import and register logsCommand
  • src/bot/commands/help.ts — Add /logs entry to the help embed

Tests

  • src/bot/commands/logs.test.ts — 10 new tests (292 total, up from 282)
    • Permission denied path
    • Missing log file → "No log entries found"
    • Default 20 lines
    • Custom N lines — correct tail shown, earlier lines excluded
    • Code-block wrapping
    • Truncation stays within 4096 chars, title marked "truncated"
    • Error handling when readFileSync throws

Coverage for logs.ts: 100% functions / 98.61% lines. No existing file coverage decreased.

Copilot AI review requested due to automatic review settings May 24, 2026 07:01
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 24, 2026

✅ Coverage Report

Metric Value
Current coverage 71.49% (1620/2266)
Baseline coverage 70.53% (1544/2189)
Result PASS

New Files

File Coverage Lines Status
src/bot/commands/logs.test.ts SKIP (ignored)
src/bot/commands/logs.ts 98.70% 76/77 PASS

Changed Files

File Baseline Current Status
src/bot/bot.ts N/A N/A SKIP (new to coverage)
src/bot/commands/help.ts N/A N/A SKIP (new to coverage)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an admin-only /logs slash command to view the tail of the bot’s logs/combined.log from within Discord, along with registration and help text updates and a new test suite.

Changes:

  • Introduce /logs command with an optional lines parameter, embed output, and truncation to Discord limits.
  • Register the new command in the bot’s command list.
  • Add /logs to the help embed and add a dedicated test file for the command.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/bot/commands/logs.ts Implements the new /logs command, file tail reading, and embed formatting/truncation.
src/bot/commands/logs.test.ts Adds unit tests covering permissions, missing file, tail selection, truncation, and errors.
src/bot/commands/help.ts Adds a help entry documenting /logs.
src/bot/bot.ts Imports and registers logsCommand for slash command deployment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bot/commands/logs.ts
Comment thread src/bot/commands/logs.ts
Comment thread src/bot/commands/logs.ts
Comment thread src/bot/commands/logs.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/bot/commands/logs.ts
Signed-off-by: Michael Cramer <michael@bigmichi1.de>
@BigMichi1 BigMichi1 force-pushed the feat/admin-logs-command branch from 48b47b8 to 66767e6 Compare May 24, 2026 09:18
@BigMichi1 BigMichi1 merged commit 03e6fb7 into main May 24, 2026
12 checks passed
@BigMichi1 BigMichi1 deleted the feat/admin-logs-command branch May 24, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants